<div>
  <div style="overflow: auto;" class="GridView">
    <div style="overflow: auto;" class="GridView" id="SearchFilterListView">
      <div>
        <div style="" class="TitleBarView">
          <h1><?php echo $this->navText;?></h1>
        </div>
      </div>
      <div>
        <div style="overflow: auto;" class="SearchView SearchView ModelView ConfigurableMetadataView MetadataView" id="AccountsSearchView">
          <div class="wide form">
          <?php $form=$this->beginWidget('CActiveForm', array(
					'id'=>'section-serach-form',
					'enableAjaxValidation'=>false,
          			'action'=>$this->createUrl('section/search', array('bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url']))
			)); ?>
              <table>
                <colgroup>
                <col style="width:20%;">
                <col style="width:30%">
                <col style="width:20%">
                <col style="width:30%">
                </colgroup>
                <tbody class="search-view-0">
                  <tr>
                    <th><?php echo $form->labelEx($searchModel,'sectionText'); ?></th>
                    <td colspan="1"><?php echo $form->textField($searchModel,'sectionText',array('maxlength'=>14)); ?></td>
                    <th><?php echo $form->labelEx($searchModel,'originalSection'); ?></th>
                    <td colspan="1"><?php echo $form->textField($searchModel,'originalSection',array('maxlength'=>14)); ?></td>
                  </tr>
                </tbody>
                <tbody class="search-view-bottom-panel">
                  <tr>
                    <td colspan="4">
                      <?php echo CHtml::submitButton('搜索'); ?>
                      &nbsp; <?php echo CHtml::link('清除搜索', array('index', 'bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url']));?>
                      <?php if ($chapter['isSortLock']!=1) :?>
                      &nbsp; ｜ &nbsp; 
                      <?php echo CHtml::link('段落排序', 'javascript:;', array('onClick'=>'jQuery("#section_order").dialog("open")'));?> 
                      <?php endif; ?>
                      <?php if ($chapter['isAddLock']!=1) :?>
                      &nbsp; | &nbsp; 
                      <?php echo CHtml::link('新建段落', array('create', 'bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url']));?>
                      <?php endif; ?>
                      &nbsp; | &nbsp;
                      <?php echo CHtml::link('查看本章前台效果', array('chapter/preview', 'bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url']), array('target'=>'_blank'));?>
						&nbsp; | &nbsp;
                      <?php echo CHtml::link('返回章节管理', array('chapter/index', 'bookFlag'=>$book->nameFlag));?>
                    </td>
                  </tr>
                </tbody>
              </table>
		  <?php $this->endWidget(); ?>
          </div>
        </div>
      </div>
      <div>
        <div style="overflow: auto;" class="SecuredListView ListView ModelView ConfigurableMetadataView MetadataView" id="ListView">
          <div class="view-toolbar"></div>
          <div id="list-view" class="cgrid-view">
            <?php if ($sections!=false) :?>
            <div class="summary">本章共<?php echo count($sections);?>段</div>
            <?php endif; ?>
            <table class="items" style="table-layout:fixed">
              <thead>
                <tr>
                  <th id="list-view_c1" style="width:5%;">段落Id</th>
                  <th id="list-view_c2" style="width:5%;">类型</th>
                  <th id="list-view_c3" style="width:5%;">排序</th>
                  <th id="list-view_c4" style="width:25%;">翻译内容</th>
                  <th id="list-view_c5" style="width:25%;">原书内容</th>
                  <th id="list-view_c6" style="width:10%;">翻译时间</th>
                  <th id="list-view_c7" style="width:5%;">评论数量</th>
                  <th id="list-view_c8" class="button-column" style="width:25%;">操作</th>
                </tr>
              </thead>
              <tbody>
              	<?php if ($sections==false) :?>
                <tr>
                  <td colspan="7"><span class="empty">无内容</span></td>
                </tr>
                <?php else :?>
                <?php foreach($sections as $section) :?>
	                <tr>
	                  <td style="word-wrap:break-word;"><?php echo $section['sectionId'];?></td>
	                  <td style="word-wrap:break-word;"><?php echo SectionHelper::getSectionType($section['sectionType']);?></td>
	                  <td style="word-wrap:break-word;"><?php echo $section['sectionSort'];?></td>
	                  <td style="word-wrap:break-word;"><?php echo CHtml::encode($section['sectionText']);?></td>
	                  <td style="word-wrap:break-word;"><?php echo CHtml::encode($section['originalSection']);?></td>
	                  <td style="word-wrap:break-word;"><?php echo date("Y-m-d H:i:s", $section['addTime']);?></td>
	                  <td style="word-wrap:break-word;"><?php echo $section['commentsCounts'];?></td>
	                  <td style="word-wrap:break-word;">
	                  <?php if ($chapter['isUpdateLock']!=1) :?>
	                  <?php echo CHtml::link('编辑原文', array('section/update', 'bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url'], 'sectionId'=> $section['sectionId']));?>
	                    | 
	                  <?php endif; ?>
	                  <?php if ($chapter['isTranslateLock']!=1) :?>
	                  <?php echo CHtml::link('翻译此段', array('section/translate', 'bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url'], 'sectionId'=> $section['sectionId']));?>
	                    | 
	                  <?php endif; ?>
	                  <?php 
		                  echo CHtml::ajaxLink(
		                  						'预览此段', 
		                  						array('section/preview', 'bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url'], 'sectionId'=> $section['sectionId']),
		                  						array('success'=>'js:function(html){ jQuery("#section_preview").html(html);	jQuery("#section_preview").dialog("open"); }')
		                  		);
		              ?>
		              
		              </td>
	                </tr>
	            <?php endforeach; ?>
                <?php endif;?>
                
              </tbody>
            </table>
            <div title="/index.php?r=accounts/default" style="display:none" class="keys"></div>
          </div>
          <input type="hidden" id="list-view-selectedIds" name="list-view-selectedIds" value="">
          <input type="hidden" id="list-view-selectAll" name="list-view-selectAll" value="">
        </div>
      </div>
    </div>
  </div>
</div>
<?php 
Yii::app()->getClientScript()->registerScript('section_order', "
jQuery('#_order').click(function() {
	jQuery.ajax({
		'type':'post',
		'url':'". $this->createUrl('section/order', array('bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url'])) ."',
		'data':{
			'SectionOrderForm[begin_num]':jQuery('#SectionOrderForm_begin_num').val(),
			'SectionOrderForm[setp_num]':jQuery('#SectionOrderForm_setp_num').val()
        },
		'dataType':'json',
		'success':function(data, status) {
			jQuery('#section_order').dialog('close');
			location.href='". $this->createUrl('section/index', array('bookFlag'=>$book->nameFlag, 'chapterFlag'=>$chapter['url'])) ."';
		},
		'error':function(data, status) {
			alert(error);
		}
	});

});

");
?>
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id'=>'section_preview', 'options'=>array('maxWidth'=>600, 'minWidth'=>600, 'maxHeight'=>450, 'minHeight'=>450, 'title'=>'预览', 'autoOpen'=>false)));
echo '&nbsp';
$this->endWidget(); 
?>
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id'=>'section_order', 'options'=>array('modal'=>true, 'maxWidth'=>600, 'minWidth'=>600, 'maxHeight'=>450, 'minHeight'=>450, 'title'=>'段落排序', 'autoOpen'=>false)));
?>
<div style="overflow: auto;" id="ModalView">
<div id="modalContainer">
<div style="overflow: auto;" class="MyListConfigView ModalConfigEditView EditView DetailsView ModelView ConfigurableMetadataView MetadataView">

<div class="wide form">
<table><colgroup><col style="width:20%"><col style="width:80%"></colgroup>
<tbody>
<tr><th><label for="SectionOrderForm_begin_num">开始数值</label></th><td colspan="1"><input type="text" value="100" name="SectionOrderForm[begin_num]" id="SectionOrderForm_begin_num">
<div style="display:none" id="SectionOrderForm_begin_num_em_" class="errorMessage"></div>会按此数值递减</td></tr>
<tr><th><label for="SectionOrderForm_setp_num">步长</label></th><td colspan="1"><input type="text" value="1" name="SectionOrderForm[setp_num]" id="SectionOrderForm_setp_num">
<div style="display:none" id="SectionOrderForm_setp_num_em_" class="errorMessage"></div>递减步长</td></tr>
</tbody></table>
此操作会按当前本章现有排序，更新排序数值
<div class="modal-view-toolbar"><input type="button" value="开始排序" name="save" id="_order"></div></form></div></div></div></div>
<?php 
$this->endWidget(); 
?>
